﻿using IPC.Client;

namespace Client
{
    class Client
    {
        static void Main(string[] args)
        {
            var thread = new NamedPipeThread("test");
            thread.SendAction += (client) =>
            {
                Console.Write("csexec> ");
                var count = Console.ReadLine();

                if (int.TryParse(count, out var value))
                {
                    var start = DateTime.Now;
                    for (var i = 0; i < value; i++)
                    {
                        var msg = $"{new Random().Next(0, 99)},{new Random().Next(0, 99)}";
                        client.Send(msg);
                        var str = client.Receive();
                        if (!string.IsNullOrEmpty(str))
                        {
                            Console.WriteLine(msg.Replace(',', '+') + str);
                        }
                    }
                    var end = DateTime.Now;
                    Console.WriteLine("执行" + (end - start).TotalMilliseconds + "毫秒");
                };
            };
            thread.Run();

            while (true)
            {

            }
        }
    }
}